Load libraries for reading fit data and create maps and plots.
Date: 16 April 2019, cycling
File: fit-test_cycling_2019-04-16_05-29-42.csv.fit
Lots of metadata from the fit file: * file id * device settings * user properties * sport / sport type * etc.
[1] "file_id" "device_settings" "user_profile" "zones_target"
[5] "sport" "session" "lap" "record"
[9] "event" "device_info" "activity" "file_creator"
[13] "hrv" "unknown"
And more specifics about the activity:
With their corresponding units:
[,1] [,2]
[1,] "accumulated_power" "watts"
[2,] "altitude" "m"
[3,] "cadence" "rpm"
[4,] "combined_pedal_smoothness" "percent"
[5,] "distance" "m"
[6,] "enhanced_altitude" "m"
[7,] "enhanced_speed" "m/s"
[8,] "fractional_cadence" "rpm"
[9,] "heart_rate" "bpm"
[10,] "left_pedal_smoothness" "percent"
[11,] "left_right_balance" ""
[12,] "left_torque_effectiveness" "percent"
[13,] "position_lat" "degrees"
[14,] "position_long" "degrees"
[15,] "power" "watts"
[16,] "right_pedal_smoothness" "percent"
[17,] "right_torque_effectiveness" "percent"
[18,] "speed" "m/s"
[19,] "temperature" "C"
[20,] "timestamp" "s"
pdata <- with(data$record, data.frame(alt = altitude, time = (timestamp-timestamp[1])/60))
ggplot(pdata, aes(y=alt, x=time)) + geom_line() +
ggtitle("Elevation vs Time") + xlab("time (minutes)") + ylab("elevation (m)")pdata <- with(data$record, data.frame(alt = altitude, time = (distance-distance[1])/1000))
ggplot(pdata, aes(y=alt, x=time)) + geom_line() +
ggtitle("Elevation vs Distance") + xlab("Distance (km)") + ylab("elevation (m)")pdata <- with(data$record, data.frame(alt = altitude, time = (distance-distance[1])/1000,
pow = power, hr=heart_rate, speed=speed, cad=cadence))
pdata <- pdata[-(1:10),]
pdata$grad <- with(data$record, 100 * diff(altitude,lag=10) / diff(distance,lag=10))
ggplot(pdata, aes(y=alt, x=time)) +
geom_line(aes(y=alt,colour="Altitude")) +
geom_line(aes(y=pow*2,colour="Power"),size=0.05) +
geom_line(aes(y=hr*2,colour="HR"),size=0.1) +
geom_line(aes(y=speed*3.69*2,colour="Speed"),size=0.1) +
geom_line(aes(y=cad*2,colour="Cadence"),size=0.05) +
geom_line(aes(y=grad*10+min(pdata$alt),colour="Gradient"),size=0.2) +
# geom_abline(intercept=min(pdata$alt), slope=0,color="orange",size=1,lty="longdash") +
geom_segment(aes(x = 0, xend = max(pdata$time), y = min(pdata$alt), yend = min(pdata$alt)),color="orange",size=0.8) +
scale_y_continuous(sec.axis = sec_axis(~./2, name = "HR (bpm) / Power (W) / Gradient (%) \n Speed (kph) / Cadence(rpm)"),
breaks = seq(0, 1000, by = 200)) +
scale_x_continuous(breaks= seq(0, 70, by = 10)) +
ggtitle("Distance vs All") +
xlab("Distance (km)") +
ylab("Altitude (m)") +
scale_colour_manual(values = c("black", "purple","orange","red","blue","green")) +
labs(y = "Altitude (m)",
x = "Distance (km)",
colour = "") +
theme_minimal() +
# theme(legend.position = c(0.9, 0.93))
theme(legend.position = "bottom")The steepest the climb, the hardest the heart has to work.
pdata <- data$record[-(1:10),c("heart_rate","timestamp")]
# compute average gradient, as %
pdata$gradient <- with(data$record, 100 * diff(altitude,lag=10) / diff(distance,lag=10))
pdata <- subset(pdata, complete.cases(pdata) & abs(gradient) < 7.5 & gradient != 0) # drop outliers
ggplot(pdata, aes(x=gradient, y=heart_rate)) +
geom_point(alpha=0.5) + geom_jitter() +
stat_smooth(method="lm", formula=y ~ poly(x, 2)) +
ggtitle("Heart rate vs gradient")With the corresponding correlation:
Call:
lm(formula = heart_rate ~ poly(gradient, 2), data = pdata)
Residuals:
Min 1Q Median 3Q Max
-88.10 -12.44 -1.12 11.48 69.91
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 136.9456 0.2314 591.83 <2e-16 ***
poly(gradient, 2)1 2121.3849 19.6863 107.76 <2e-16 ***
poly(gradient, 2)2 264.0658 19.6863 13.41 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 19.69 on 7235 degrees of freedom
Multiple R-squared: 0.6198, Adjusted R-squared: 0.6196
F-statistic: 5896 on 2 and 7235 DF, p-value: < 2.2e-16
And averages for each gradient step:
[,1] [,2] [,3] [,4] [,5] [,6] [,7]
gradient -6.00000 -4.0000 -2.000 0.0000 2.0000 4.0000 6.0000
heart_rate 96.57316 105.1922 115.464 127.3885 140.9658 156.1958 173.0786
Convert time to minutes and add direction (Outbound vs Return):
# points <- subset(data$record, complete.cases(data$record))
points <- data$record
points$time_min <- with(points, timestamp - timestamp[1])/60 # minutes of riding
# from diagram above, we turned around at the 90 minutes mark
# points[which(points$altitude == max(points$altitude)),]
points$direction <- with(points, factor(ifelse(time_min < 90, 'Outbound', 'Return'))) # library(leaflet)
# leaflet(points[points$direction == 'Outbound',]) %>% addTiles() %>% addPolylines(~position_long,~position_lat)
# leaflet(points[points$direction == 'Return',]) %>% addTiles() %>% addPolylines(~position_long,~position_lat)The darker the colour, the higher the HR is:
newcols <- rev(cet_pal(min(dim(points)[1],256),name="l3"))
points <- points %>% mutate(quantile=ntile(heart_rate,256))
newcols.quantile <- newcols[points$quantile]
points1 <- points %>%
mutate(nextLat = lead(position_lat),
nextLng = lead(position_long),
color = newcols.quantile
)
gradient_map <- leaflet() %>%
addTiles()
# points1 <- points1[points1$direction == 'Outbound',]
for (i in 1:nrow(points1)) {
gradient_map <- addPolylines(map = gradient_map,
data = points1,
lng = as.numeric(points1[i, c('position_long', 'nextLng')]),
lat = as.numeric(points1[i, c('position_lat', 'nextLat')]),
color = as.character(points1[i, c('color')])
)
}
gradient_mapAnd we can overlap different measurements to the same plot. The darker the colour, the higher the HR and the higher the altitude (for the new line):
newcols <- rev(cet_pal(min(dim(points)[1],256),name="l3"))
newcols_alt <- rev(cet_pal(min(dim(points)[1],256),name="l7"))
points <- points %>% mutate(quantile=ntile(heart_rate,256))
points <- points %>% mutate(quantile_alt=ntile(altitude,256))
newcols.quantile <- newcols[points$quantile]
points1 <- points %>%
mutate(nextLat = lead(position_lat),
nextLng = lead(position_long),
color = newcols.quantile,
color_alt = newcols_alt[points$quantile_alt]
)
gradient_map <- leaflet() %>% addTiles()
# points1 <- points1[points1$direction == 'Outbound',]
for (i in 1:nrow(points1)) {
# for (i in 1:500) {
gradient_map <- addPolylines(map = gradient_map,
data = points1,
lng = as.numeric(points1[i, c('position_long', 'nextLng')]),
lat = as.numeric(points1[i, c('position_lat', 'nextLat')]),
color = as.character(points1[i, c('color')])
)
}
for (i in 1:which.max(points1$quantile_alt)) {
# for (i in 1:500) {
gradient_map <- addPolylines(map = gradient_map,
data = points1,
lng = as.numeric(points1[i, c('position_long', 'nextLng')])-0.005,
lat = as.numeric(points1[i, c('position_lat', 'nextLat')])-0.005,
color = as.character(points1[i, c('color_alt')])
)
}
gradient_mapFunction to create map:
create_map_fit <- function (fit_data,alt){
points <- fit_data$record
newcols <- rev(cet_pal(min(dim(points)[1],256),name="l3"))
newcols_alt <- rev(cet_pal(min(dim(points)[1],256),name="l7"))
points <- points %>% mutate(quantile=ntile(heart_rate,256))
if (alt == TRUE) {
points <- points %>% mutate(quantile_alt=ntile(altitude,256))
}
if (alt == TRUE) {
points1 <- points %>% mutate(nextLat = lead(position_lat),
nextLng = lead(position_long),
color = newcols[points$quantile],
color_alt = newcols_alt[points$quantile_alt])
} else {
points1 <- points %>% mutate(nextLat = lead(position_lat),
nextLng = lead(position_long),
color = newcols[points$quantile])
}
#prepare map
gradient_map <- leaflet() %>% addTiles()
for (i in 1:nrow(points1)) {
gradient_map <- addPolylines(map = gradient_map,
data = points1,
lng = as.numeric(points1[i, c('position_long', 'nextLng')]),
lat = as.numeric(points1[i, c('position_lat', 'nextLat')]),
color = as.character(points1[i, c('color')]))
}
if (alt == TRUE) {
# for (i in 1:which.max(points1$quantile_alt)) {
for (i in 1:nrow(points1)) {
gradient_map <- addPolylines(map = gradient_map,
data = points1,
lng = as.numeric(points1[i, c('position_long', 'nextLng')])-0.005,
lat = as.numeric(points1[i, c('position_lat', 'nextLat')])-0.005,
color = as.character(points1[i, c('color_alt')]))
}
}
gradient_map
}t <- read.fit("SELECTED_FILES/WhiteLiam/09/WhiteL1994.2019-09-20-23-05-29-293Z.GarminPush.40964805705.fit")
create_map_fit(t,alt=TRUE)We want to calculate different predictors based on the training activity: Phase 1 will contain:
Read activity data (Only 1 for the moment, but will loop through all activities later):
# data <- read.fit('fit-test_cycling_2019-04-16_05-29-42.csv.fit')
# data <- read.fit('RAW/WorkoutFileExport-White-Liam-2019-04-01-2019-10-01/WhiteL1994.2019-04-16-07-58-54-572Z.GarminPush.33102899171.fit')
data <- read.fit('RAW/WorkoutFileExport-White-Liam-2019-04-01-2019-10-01/WhiteL1994.2019-04-17-08-34-41-343Z.GarminPush.33150696869.fit')
baddata <- read.fit("SELECTED_FILES/WhiteLiam/09/WhiteL1994.2019-09-12-07-01-07-759Z.GarminPush.40489308023.fit")Initialize predictors df with activity id:
activity.time <- round((max(data$record$timestamp)-data$record$timestamp[1])/60,2)
predictors$time.min <- activity.timepredictors$hrmax.athlete <- data$zones_target$max_heart_rate
predictors$hrmax.activity <- max(data$record$heart_rate)
predictors$hrmax.perc <- round(predictors$hrmax.activity/predictors$hrmax.athlete*100,2)
predictors$hrmax.intensity <- predictors$hrmax.perc * predictors$time.minhr.zones <- quantile(c(1:predictors$hrmax.athlete),probs=seq(0,1,by=0.1))
# we want zones 1 to 5
data$record$hr.zones <- findInterval(data$record$heart_rate,hr.zones[6:10])
hr.zones.table <- round(table(data$record$hr.zones)/sum(table(data$record$hr.zones))*100,1)
predictors$hr.z5 <- hr.zones.table[6]
predictors$hr.z4 <- hr.zones.table[5]
predictors$hr.z3 <- hr.zones.table[4]
predictors$hr.z2 <- hr.zones.table[3]
predictors$hr.z1 <- hr.zones.table[2]# predictors$hr.avg <- mean(data$record$heart_rate)
predictors$hr.avg <- data$session$avg_heart_ratesport_code <- c(0,1,2,5,10,15)
sport_type <- c("Undefined","Running","Cycling","Swimming","Rowing")
predictors$sport_code <- data$session$sport
predictors$sport_type <- sport_type[which (sport_code == predictors$sport_code)]
predictors$speed.avg <- round(data$session$avg_speed*3.79,1)predictors$power.max <- data$session$max_power
predictors$power.avg <- data$session$avg_power
predictors$power.norm <- data$session$normalized_powerWhich will give us a table as follows:
We will have VO2max for all participants (Name, VO2max, Weight):
library(purrr)
vo2max <- read.csv("VO2maxdata.csv")
vo2max <- vo2max[vo2max$EventName == "Baseline",]
row.names(vo2max) <- 1:nrow(vo2max)
vo2max <- vo2max %>% mutate(name= map(strsplit(as.character(Athlete), "(?!^)(?=[[:upper:]])", perl=T),~.x[1]) %>% unlist())
vo2maxGet all files for the 10 athletes (September 2019):
dirs <- list.dirs("SELECTED_FILES",recursive=F)
for (ath in vo2max$name){
k <- paste0(dirs[grep(tolower(ath),tolower(dirs))],"/09")
print(k)
print(head(list.files(k),1))
}[1] "SELECTED_FILES/WhiteLiam/09"
[1] "WhiteL1994.2019-09-01-03-14-36-346Z.GarminPush.39879313546.fit"
[1] "SELECTED_FILES/MichelmoreKatie/09"
[1] "katiemichelmore.2019-09-04-00-33-02-272Z.GarminPush.40039260489.fit"
[1] "SELECTED_FILES/WhiteNicholas/09"
[1] "nickwhitey97.2019-09-01-13-48-28-116Z.GarminPush.39904430313.fit"
[1] "SELECTED_FILES/JennerSamuel/09"
[1] "2019-09-01-095353-ELEMNT BOLT 6A50-69-0.fit"
[1] "SELECTED_FILES/LoneraganBryn/09"
[1] "bloneragan.2019-09-01-05-32-27-608Z.GarminPush.39882875786.fit"
[1] "SELECTED_FILES/WillOckenden/09"
[1] "2019-09-03-191932-ELEMNT BOLT 8AFB-140-0.fit"
[1] "SELECTED_FILES/PaolilliDomenic/09"
[1] "DomenicPaolilli.2019-09-04-05-08-40-874Z.GarminPush.40048137906.fit"
[1] "SELECTED_FILES/Veriskirstydeacon/09"
[1] "kirstydeacon.2019-09-01-03-46-50-971Z.GarminPush.39879951239.fit"
[1] "SELECTED_FILES/AlbrechtJasper/09"
[1] "ALBRECHT1.2019-09-01-09-40-41-058Z.GarminPush.39893460390.fit"
[1] "SELECTED_FILES/McKennaDylan/09"
[1] "dylanmckenna98.2019-09-01-05-07-55-531Z.GarminPush.39882056069.fit"
Our goal now is to create a framework that inputs a list of files and returns a table with all predictors. First for all Fit files of athletes and then, calculate totals and averages for each of the athletes.
Get all WhiteLiam files
And create a function to calculate all predictors as previously, given a list of Fit files:
calc_predictors <- function (fitFiles) {
#initialize predictors
all.predictors <- as.data.frame(matrix(vector(),ncol=25))
colnames(all.predictors) <- c("activity.id","time.min","hrmax.athlete","hrmax.activity",
"hrmax.perc","hrmax.intensity","hr.z5","hr.z4","hr.z3",
"hr.z2","hr.z1","week","hr.avg","sport_code","sport_type","speed.avg","cal",
"ascent","power.max","power.avg","power.norm","work",
"stress.score","total.dist","intensity.factor")
activity.id = 1
for (myfile in fitFiles) {
# print(myfile)
data <- read.fit(myfile)
#check if there are NAs in data$record (some cases seen) --> JennerSamuel [5]
# if t
predictors <- as.data.frame(matrix(NA,ncol=25))
colnames(predictors) <- c("activity.id","time.min","hrmax.athlete","hrmax.activity",
"hrmax.perc","hrmax.intensity","hr.z5","hr.z4","hr.z3",
"hr.z2","hr.z1","week","hr.avg","sport_code","sport_type",
"speed.avg","cal",
"ascent","power.max","power.avg","power.norm","work",
"stress.score","total.dist","intensity.factor")
activity.time <- round((max(data$record$timestamp)-data$record$timestamp[1])/60,2)
predictors$time.min <- activity.time
predictors$activity.id <- activity.id
#check if there is heart_rate info (not in swimming, surfing and other watersports)
if(is.null(data$zones_target$max_heart_rate)){
predictors$hrmax.athlete <- 200
} else {
predictors$hrmax.athlete <- data$zones_target$max_heart_rate
}
if (any(names(data$record) %in% "heart_rate")){
predictors$hrmax.activity <- max(data$record$heart_rate
[1:(length(data$record$heart_rate)-3)],na.rm=T)
predictors$hrmax.perc <- round(predictors$hrmax.activity/predictors$hrmax.athlete*100,2)
predictors$hrmax.intensity <- predictors$hrmax.perc * predictors$time.min
hr.zones <- quantile(c(1:predictors$hrmax.athlete),probs=seq(0,1,by=0.1))
data$record$hr.zones <- findInterval(data$record$heart_rate,hr.zones[6:10])
hr.zones.table<-round(table(data$record$hr.zones)/sum(table(data$record$hr.zones))*100,1)
predictors$hr.z5 <- hr.zones.table[6]
predictors$hr.z4 <- hr.zones.table[5]
predictors$hr.z3 <- hr.zones.table[4]
predictors$hr.z2 <- hr.zones.table[3]
predictors$hr.z1 <- hr.zones.table[2]
predictors$hr.avg <- data$session$avg_heart_rate
} else {
predictors$hrmax.athlete <- NA
predictors$hrmax.activity <- NA
predictors$hrmax.perc <- NA
predictors$hrmax.intensity <- NA
predictors$hr.z5 <- NA
predictors$hr.z4 <- NA
predictors$hr.z3 <- NA
predictors$hr.z2 <- NA
predictors$hr.z1 <- NA
predictors$hr.avg <- NA
}
predictors$week <- 1
predictors$sport_code <- data$session$sport
predictors$sport_type <- sport_type[which (sport_code == predictors$sport_code)]
predictors$speed.avg <- round(data$session$avg_speed*3.79,1)
predictors$cal <- if(is.null(data$session$total_calories)){NA}else{data$session$total_calories}
predictors$ascent <- if(is.null(data$session$total_ascent)){NA}else{data$session$total_ascent}
predictors$power.max <- if(is.null(data$session$max_power)){NA}else{data$session$max_power}
predictors$power.avg <- if(is.null(data$session$avg_power)){NA}else{data$session$avg_power}
predictors$power.norm <- if(is.null(data$session$normalized_power)){NA}else{data$session$normalized_power}
predictors$work <- if(is.null(data$session$total_work)){NA}else{data$session$total_work}
predictors$stress.score <- if(is.null(data$session$training_stress_score)){NA}
else {data$session$training_stress_score}
predictors$total.dist <- data$session$total_distance
predictors$intensity.factor <- if(is.null(data$session$intensity_factor)){NA}
else{data$session$intensity_factor}
all.predictors <- rbind(all.predictors,predictors)
activity.id <- activity.id+1
# print(all.predictors)
}
return(all.predictors)
}The function created above gives us the following results for the test with WhiteLiam files:
Superpredictors are averages or totals of each of the activity predictors, as a way to summarize training data for each athlete during the selected period. Here we calculate all of them to compare with vo2max in the final step.
Define function to: * Initialize variables
# final.data <- vo2max
prep_superpredictors <- function(final.data){
final.data$activities.total <- NA
final.data$time.total <- NA
final.data$time.avg <- NA
final.data$hrmax.perc.avg <- NA
final.data$hrmax.max <- NA
final.data$hrmax.intensity.total <- NA
final.data$hrmax.intensity.avg <- NA
final.data$hr.z5.avg <- NA
final.data$hr.z4.avg <- NA
final.data$hr.z3.avg <- NA
final.data$hr.z2.avg <- NA
final.data$hr.z1.avg <- NA
final.data$hr.avg <- NA
final.data$cal.total <- NA
final.data$cal.avg <- NA
final.data$power.avg <- NA
final.data$work.avg <- NA
final.data$stress.score.avg <- NA
final.data$dist.total <- NA
final.data$dist.avg <- NA
final.data$intensity.factor.avg <- NA
return(final.data)
}# ath <- 'Liam'
get_superpredictors <- function (ath.data,ath.predictors,ath.name) {
ath.data[ath.data$name == ath.name,]$activities.total <- nrow(ath.predictors)
ath.data[ath.data$name == ath.name,]$time.total <- sum(ath.predictors$time.min)
ath.data[ath.data$name == ath.name,]$time.avg <- mean(ath.predictors$time.min,na.rm=T)
ath.data[ath.data$name == ath.name,]$hrmax.perc.avg <- mean(ath.predictors$hrmax.perc,na.rm=T)
ath.data[ath.data$name == ath.name,]$hrmax.max <- if (sum(!is.na(ath.predictors$hrmax.activity)) == 0 ){NA}else{max(ath.predictors$hrmax.activity,na.rm=T)}
ath.data[ath.data$name == ath.name,]$hrmax.intensity.total <- sum(ath.predictors$hrmax.intensity,na.rm=T)
ath.data[ath.data$name == ath.name,]$hrmax.intensity.avg <- mean(ath.predictors$hrmax.intensity,na.rm=T)
ath.data[ath.data$name == ath.name,]$hr.z5.avg <- mean(ath.predictors$hr.z5,na.rm=T)
ath.data[ath.data$name == ath.name,]$hr.z4.avg <- mean(ath.predictors$hr.z4,na.rm=T)
ath.data[ath.data$name == ath.name,]$hr.z3.avg <- mean(ath.predictors$hr.z3,na.rm=T)
ath.data[ath.data$name == ath.name,]$hr.z2.avg <- mean(ath.predictors$hr.z2,na.rm=T)
ath.data[ath.data$name == ath.name,]$hr.z1.avg <- mean(ath.predictors$hr.z1,na.rm=T)
ath.data[ath.data$name == ath.name,]$hr.avg <- mean(ath.predictors$hr.avg,na.rm=T)
ath.data[ath.data$name == ath.name,]$cal.total <- sum(ath.predictors$cal,na.rm=T)
ath.data[ath.data$name == ath.name,]$cal.avg <- mean(ath.predictors$cal,na.rm=T)
ath.data[ath.data$name == ath.name,]$power.avg <- mean(ath.predictors$power.avg,na.rm=T)
ath.data[ath.data$name == ath.name,]$work.avg <- mean(ath.predictors$work,na.rm=T)
ath.data[ath.data$name == ath.name,]$stress.score.avg <- mean(ath.predictors$stress.score,na.rm=T)
ath.data[ath.data$name == ath.name,]$dist.total <- sum(ath.predictors$total.dist,na.rm=T)
ath.data[ath.data$name == ath.name,]$dist.avg <- mean(ath.predictors$total.dist,na.rm=T)
ath.data[ath.data$name == ath.name,]$intensity.factor.avg <- mean(ath.predictors$intensity.factor,na.rm=T)
ath.data[is.na(ath.data)] <- NA
return(ath.data)
}Combine the reading of the files with the superpredictor calculation
for (ath in vo2max$name){
# for (ath in 'Liam'){
ath.folder <- paste0(dirs[grep(tolower(ath),tolower(dirs))],"/09/")
myfiles <- paste0(ath.folder, list.files(paste0(ath.folder)))
#get predictors
ath.predictors <- calc_predictors(myfiles)
#get superpredictors
ath.superpreds <- get_superpredictors(ath.superpreds,ath.predictors,ath)
}And the final results for all the athletes:
Correlate all superpredictors with VO2max. Each point corresponds to an athlete:
models <- as.data.frame(matrix(NA,ncol=22))
models <- rbind(models,NA)
row.names(models) <- c("rsquare","pvalue")
colnames(models) <- names(ath.superpreds)[c(5,7:dim(ath.superpreds)[2])]for (mod in names(models)){
md <- paste("VO2max ~ ",mod,sep = "")
lmTemp = lm(md, data = ath.superpreds) #Create the linear regression
plot(ath.superpreds[[mod]],ath.superpreds$VO2max, pch = 16, col = "blue",xlab=mod,ylab="VO2max") #Plot the results
abline(lmTemp) #Add a regression line
# print(summary(lmTemp))
models[[mod]] <- c(summary(lmTemp)$adj.r.squared,summary(lmTemp)$coefficients[2,4])
}md <- paste("VO2max ~ ",paste(names(models)[1:3],collapse="+"),sep = "")
lmTemp = lm(md, data = ath.superpreds) #Create the linear regression
plot(ath.superpreds[[mod]],ath.superpreds$VO2max, pch = 16, col = "blue",xlab=mod,ylab="VO2max") #Plot the results
abline(lmTemp) #Add a regression lineonly using the first two of 4 regression coefficients
# print(summary(lmTemp))
models$ALL <- c(summary(lmTemp)$adj.r.squared,summary(lmTemp)$coefficients[2,4])
summary(lmTemp)
Call:
lm(formula = md, data = ath.superpreds)
Residuals:
Min 1Q Median 3Q Max
-0.56419 -0.24564 0.02118 0.28234 0.40622
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 4.4153795 2.2613275 1.953 0.0987 .
Weight -0.0052206 0.0382897 -0.136 0.8960
activities.total -0.0181568 0.0339628 -0.535 0.6121
time.total 0.0001865 0.0001143 1.631 0.1540
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.4167 on 6 degrees of freedom
Multiple R-squared: 0.4025, Adjusted R-squared: 0.1037
F-statistic: 1.347 on 3 and 6 DF, p-value: 0.3449